#ifndef REMOTE_SERVER_QUERY_STANZA_H_
#define REMOTE_SERVER_QUERY_STANZA_H_

#include "vzbase/base/boostsettings.h"
#include "vzbase/base/basictypes.h"
#include "vzconn/base/bytebuffer.h"
#include "json/json.h"

namespace remote {

class QueryStanza : public boost::noncopyable,
  public boost::enable_shared_from_this < QueryStanza > {
 public:
  typedef boost::shared_ptr<QueryStanza> Ptr;
  static QueryStanza::Ptr CreateQueryStanza(
    const std::string type,
    uint32 state,
    const std::string id,
    const std::string to,
    const std::string from);
  QueryStanza();
  virtual ~QueryStanza();

  const std::string type() {
    return type_;
  }
  void set_type(const std::string type) {
    type_ = type;
  }
  uint32 state() {
    return state_;
  }
  void set_state(uint32 state) {
    state_ = state;
  }
  const std::string id() {
    return id_;
  }
  void set_id(const std::string id) {
    id_ = id;
  }
  const std::string to() {
    return to_;
  }
  void set_to(const std::string to) {
    to_ = to;
  }
  const std::string from() {
    return from_;
  }
  void set_from(const std::string from) {
    from_ = from;
  }
  const Json::Value body() {
    return body_;
  }
  void set_body(const Json::Value body) {
    body_ = body;
  }

  vzconn::ByteBuffer::Ptr ToByteBuffer();
  bool Parse(const char *data, std::size_t size);
  bool IsValid();
  std::string ToString();
 private:
  std::string type_;
  uint32      state_;
  std::string id_;
  std::string to_;
  std::string from_;
  Json::Value body_;
};
}

#endif  // REMOTE_SERVER_QUERY_STANZA_H_
